package com.prs.crm.dao.sys.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.sys.VoteAdminDao;
import com.prs.crm.domain.sys.VoteAdmin;

public class VoteAdminDaoImpl extends BaseDaoImpl<VoteAdmin> implements VoteAdminDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<VoteAdmin> getAllVoteAdmin() {
		Criteria criteria=this.getSession().createCriteria(VoteAdmin.class);
		return criteria.list();
	}

	@Override
	public VoteAdmin getVoteAdmin(final String code) {
		Criteria criteria=this.getSession().createCriteria(VoteAdmin.class);
		criteria.add(Restrictions.eq("type", code));
		List result=criteria.list();
		if (result==null || result.size()==0) {
			return null;
		}
		return (VoteAdmin) criteria.list().get(0);
	}
}
